From 3c12c9f3db526aff2026703820a8c77875ecdf71 Mon Sep 17 00:00:00 2001 From: james_sherring Date: Fri, 5 Dec 2003 11:24:29 +0000 Subject: [PATCH] cleanup various debug items, no input file condition bug fix --- st2gpx/src/annotations.c | 37 ++++---- st2gpx/src/contents.c | 33 +++---- st2gpx/src/debug.c | 180 +++------------------------------------ st2gpx/src/journey.c | 40 ++++----- st2gpx/src/ppinutil.c | 30 +++---- st2gpx/src/properties.c | 94 ++++++++++---------- st2gpx/src/readgpx.c | 66 +++++++------- st2gpx/src/st2gpx.c | 89 +++++-------------- st2gpx/src/st2gpx.dsp | 105 ++++------------------- st2gpx/src/st2gpx.h | 2 - st2gpx/src/writegpx.c | 10 +-- st2gpx/src/writepcx.c | 40 ++++----- 12 files changed, 224 insertions(+), 502 deletions(-) diff --git a/st2gpx/src/annotations.c b/st2gpx/src/annotations.c index c3a3f5197..e737ba805 100644 --- a/st2gpx/src/annotations.c +++ b/st2gpx/src/annotations.c @@ -61,19 +61,19 @@ char std_annot_linerec_header_v4[LINE_REC_LEN_V4] = // type annot#1 , {0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // 0x00 - 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, //show length, // order //behind roads - 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // blue 2pt - 0x12, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, // show line - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //struct parameters { @@ -131,9 +131,9 @@ void annot_rec_delete(struct annot_rec * annot_rec) if (annot_rec==NULL) return; //for(i=0; iline_points) - xfree(annot_rec->buf); - xfree(annot_rec->text); - xfree(annot_rec); + free(annot_rec->buf); + free(annot_rec->text); + free(annot_rec); } struct annotations * annotations_new() @@ -159,9 +159,9 @@ void annotations_delete(struct annotations * annots) for (i=0; inum_annotations; i++) annot_rec_delete(annots->annot_list[i]); - xfree(annots->annot_list); - xfree(annots->header_buf); - xfree(annots); + free(annots->annot_list); + free(annots->header_buf); + free(annots); } struct gpxpt* gpx_get_point(char* buf) @@ -276,12 +276,12 @@ struct annot_rec * read_annot_rec(FILE* annot_in_file, int version) } } - if (rec->type == ANNOT_TYPE_LINE) + if (rec->type == ANNOT_TYPE_LINE) rec->line_offset = line_offset; if (rec->type<4) rec_type =annot_type_name[rec->type]; - else + else rec_type=NULL; if (opts.verbose_flag > 4) @@ -383,9 +383,8 @@ struct annotations * process_annotations_stream(char* annot_in_file_name) { rec = read_annot_rec(annot_in_file, annots->version); - // current version of explore annots is a bit childish -// if (opts.explore_flag) -// explore_annot(rec); + if (opts.explore_flag) + explore_annot(rec); if (rec==NULL) { annots->read_recs_ok_flag = 0; @@ -412,7 +411,7 @@ struct annotations * process_annotations_stream(char* annot_in_file_name) } else annots->read_tail_ok_flag=1; - xfree(checkEOF); + free(checkEOF); } fclose(annot_in_file); return annots; diff --git a/st2gpx/src/contents.c b/st2gpx/src/contents.c index ee6bf4aec..513420f34 100644 --- a/st2gpx/src/contents.c +++ b/st2gpx/src/contents.c @@ -71,10 +71,13 @@ struct contents * contents_new() void contents_delete(struct contents * conts) { - xfree(conts->list_f_pcbtext); - xfree(conts->list_f_text); - xfree(conts->buf); - xfree(conts); + if(conts != NULL) + { + free(conts->list_f_pcbtext); + free(conts->list_f_text); + free(conts->buf); + } + free(conts); } void print_f_contents0(struct f_contents0 * conts) @@ -217,17 +220,17 @@ struct contents * parse_contents_buffer(char* buf, unsigned int buf_len) printf("Array[%d]=%d - unknown meaning\n", i, conts->f_conts_array[i]); printf("n:=Array[3]=%d is number of user pushpin sets\n", (conts->f_conts_array)[3]); - + // for(i=0; i< (conts->f_conts_array[3]); i++) -// printf("Array[%d]=%d is SetId for user PushpinSet[%d] \n", +// printf("Array[%d]=%d is SetId for user PushpinSet[%d] \n", // 4+i, // conts->f_conts_array[4+i], -// conts->f_conts_array[3] - i -1); +// conts->f_conts_array[3] - i -1); for(i=0; i< (conts->f_conts_array[3]); i++) printf("Array[4+n-(%d)]=%d is SetId for user PushpinSet[%d]\n", i, conts->f_conts_array[3+(conts->f_conts_array[3])-i], i); - + for(i=0; (4 + (conts->f_conts_array[3] +i)) < (conts->f_conts0->array_len)/2 ; i++) printf("Array[5+n+(%d)]=%d - unknown meaning\n", i, conts->f_conts_array[4+(conts->f_conts_array[3])+i]); @@ -235,7 +238,7 @@ struct contents * parse_contents_buffer(char* buf, unsigned int buf_len) debug_pause(); // printf("Dumping Contents array tail:\n"); -// printbuf((char*)(conts->f_conts_array + 4 + conts->f_conts_array[3]), +// printbuf((char*)(conts->f_conts_array + 4 + conts->f_conts_array[3]), // (conts->f_conts0->array_len)-2*(4 + conts->f_conts_array[3]) ); } @@ -263,7 +266,7 @@ struct contents * parse_contents_buffer(char* buf, unsigned int buf_len) { temp_str=buf2str(conts->f_text0, *(conts->f_pcbtext0)); printf("Got Text0='%s'\n", temp_str); - xfree(temp_str); + free(temp_str); temp_str=NULL; } @@ -296,7 +299,7 @@ struct contents * parse_contents_buffer(char* buf, unsigned int buf_len) { temp_str=buf2str(conts->f_text1, conts->f_conts1->cbText1); printf("Got Text1='%s'\n", temp_str); - xfree(temp_str); + free(temp_str); temp_str=NULL; } @@ -347,7 +350,7 @@ struct contents * parse_contents_buffer(char* buf, unsigned int buf_len) { temp_str = buf2str(conts->list_f_text[i], *(conts->list_f_pcbtext[i])); printf("Got list_text[%d]='%s'\n", i, temp_str); - xfree(temp_str); + free(temp_str); } } @@ -356,7 +359,7 @@ struct contents * parse_contents_buffer(char* buf, unsigned int buf_len) // ************************** conts->pusunkn0 = (unsigned short*)(conts->buf+buf_pos); - + buf_pos += sizeof(unsigned short); if (buf_pos>(conts->buf_len)) { @@ -409,7 +412,7 @@ struct contents * parse_contents_buffer(char* buf, unsigned int buf_len) temp_str=buf2str(conts->CountryText, conts->f_conts3->cbCountryText); if(opts.explore_flag) printf("Got CountryText='%s'\n", temp_str); - xfree(temp_str); + free(temp_str); temp_str=NULL; } @@ -417,7 +420,7 @@ struct contents * parse_contents_buffer(char* buf, unsigned int buf_len) conts->fully_parsed_flag=1; else { - printf("Unexpected %d bytes of contents buffer still remaining.\n", + printf("Unexpected %d bytes of contents buffer still remaining.\n", (conts->buf_len)-buf_pos); printbuf((conts->buf)+buf_pos, (conts->buf_len)-buf_pos); } diff --git a/st2gpx/src/debug.c b/st2gpx/src/debug.c index e1cf06f5a..675338d0b 100644 --- a/st2gpx/src/debug.c +++ b/st2gpx/src/debug.c @@ -50,23 +50,8 @@ void debug_pause() } } -int fixhex(char c) -{ -// gcc (version?) does not print single byte hex values properly -// eg 0xe3 prints as 0xFFFFFFE3 -// this is only a problem for values above 0x80 -// Or maybe that is the proper handling of unsigned? -// Aaaahhh. I should use %u for printing unsigned... but the hex problem is still there - if(c & 0x80) - { - return ((int)c-0xFFFFFF00); - } else - return c; -} - void printbuf(char* buf, int len) { -// unsigned i; int i; printf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F\n"); printf(" -----------------------------------------------"); @@ -74,59 +59,7 @@ void printbuf(char* buf, int len) { if (((i+1) & 0x0f) == 0x1) printf("\n%2x| ",i/16); - printf("%2x ",fixhex(buf[i])); - } - printf("\n\n"); -} - -void printbufwide(char* buf, int len) -{ - int i; - for(i=0; ilat, pt->lon, pt->elevation); - gpxpt_delete(pt); - fflush(stdout); - } - printf("\n\n"); -} - -void printnzbuf(char* buf, int len) -{ -// print non-zero values in the buffer -// unsigned i; - int i; - for(i=0; ibuf, ANNOT_RECOS_TEXT); - memcpy(header+ANNOT_RECOS_TEXT+2*rec->text_length, rec->buf, - ANNOT_REC_HEAD_LEN-ANNOT_RECOS_TEXT); - - tail = rec->buf+ANNOT_REC_HEAD_LEN+2*rec->text_length; - taillength = rec->length - ANNOT_REC_HEAD_LEN+2*rec->text_length; - - printf("Record buffer\n", annot_type_name[rec->type]); - printbuf(rec->buf, rec->length); - printf("Record high buffer\n", annot_type_name[rec->type]); - printbufhigh(rec->buf, rec->length); - printf("Record wide header:\n", annot_type_name[rec->type]); - printbufwide(header, ANNOT_REC_HEAD_LEN); - printf("Record tail:\n"); - printbuf(tail, taillength); - printf("Record wide tail:\n"); - printbufwide(tail, taillength); - printf("Record tail as floats:\n"); - printbufasfloat(tail, taillength); - printf("Record tail as points:\n"); - printbufaspoints(tail, taillength); -// if (rec->type == ANNOT_TYPE_TEXT) -// { - //printfloatbuf((float*)(tail+3), taillength/4 -1); -// } -// else if (rec->type == ANNOT_TYPE_OVAL ) -// printfloatbuf((float*)(tail+3), taillength/4 -1); -// else if (rec->type == ANNOT_TYPE_CIRCLE )) -// printfloatbuf((float*)(tail+3), taillength/4 -1); - xfree(header); } void print_f_jour_header(struct f_jour_header * head) @@ -266,17 +106,17 @@ void print_f_jour_pt_head(struct f_jour_pt_head * pt_head) printf("iunkn0 %#x=%d\n", pt_head->iunkn0, pt_head->iunkn0); printf("sched_arrive_flag %d\n", pt_head->sched_arrive_flag); printf("sched_depart_flag %d\n", pt_head->sched_depart_flag); - printf("arrive_time_secs %d\n", pt_head->arrive_time_secs); + printf("arrive_time_secs %d\n", pt_head->arrive_time_secs); printf("depart_time_secs %d\n", pt_head->depart_time_secs); printf("iunkn1 %#x=%d\n", pt_head->iunkn1, pt_head->iunkn1); // x = pt_head->unkn_scaled_lon; // x = x*360/0x10000; // x = x/0x10000; - printf("scaled_lon %d gives lon %f\n", + printf("scaled_lon %d gives lon %f\n", pt_head->scaled_lon, scaled2deg(pt_head->scaled_lon)); // x = (pt_head->unkn_scaled_lat*360/0x10000); // x = x/0x10000; - printf("scaled_lat %d gives lat %f\n", + printf("scaled_lat %d gives lat %f\n", pt_head->scaled_lat, scaled2deg(pt_head->scaled_lat)); printf("cbtext1 %d\n",pt_head->cbtext1); printbuf((char*)pt_head, sizeof(struct f_jour_pt_head)); @@ -293,16 +133,16 @@ void print_f_jour_pt_tail(struct f_jour_pt_tail * pt_tail) printf("road_id %x=%d\n", pt_tail->road_id, pt_tail->road_id); printf("dist_along_rd_frac %lf \n", pt_tail->dist_along_rd_frac); - printf("rd_arrive_sc_lat %d gives lat %f\n", + printf("rd_arrive_sc_lat %d gives lat %f\n", pt_tail->rd_arrive_sc_lat, scaled2deg(pt_tail->rd_arrive_sc_lat)); - printf("rd_arrive_sc_lon %d gives lat %f\n", + printf("rd_arrive_sc_lon %d gives lat %f\n", pt_tail->rd_arrive_sc_lon, scaled2deg(pt_tail->rd_arrive_sc_lon)); - printf("rd_depart_sc_lat %d gives lat %f\n", + printf("rd_depart_sc_lat %d gives lat %f\n", pt_tail->rd_depart_sc_lat, scaled2deg(pt_tail->rd_depart_sc_lat)); - printf("rd_depart_sc_lon %d gives lat %f\n", + printf("rd_depart_sc_lon %d gives lat %f\n", pt_tail->rd_depart_sc_lon, scaled2deg(pt_tail->rd_depart_sc_lon)); printf("iunkn8 %x=%d\n", pt_tail->iunkn8, pt_tail->iunkn8); @@ -544,9 +384,9 @@ void print_annotations(struct annotations * annots) int i; // This is only the main stuff printf("Annotations list, version=%d, num_annotations=%d, max_annot_num=%d, stream_length=%d\n", - annots->version, annots->num_annotations, + annots->version, annots->num_annotations, annots->max_annot_num, annots->stream_length); - + for(i=0; inum_annotations; i++) print_annot_rec(annots->annot_list[i]); } diff --git a/st2gpx/src/journey.c b/st2gpx/src/journey.c index e8fa65e52..7a1a9619a 100644 --- a/st2gpx/src/journey.c +++ b/st2gpx/src/journey.c @@ -65,10 +65,10 @@ void jour_rtept_delete(struct jour_rtept * jourpt) { if (jourpt==NULL) return; - xfree(jourpt->text1); - xfree(jourpt->text2); + free(jourpt->text1); + free(jourpt->text2); // This is part of an array, so free the array - //xfree(jourpt); + //free(jourpt); } struct journey * journey_new() @@ -94,14 +94,14 @@ void journey_delete(struct journey * jour) return; for(i=0; i< jour->count_rtepts; i++) jour_rtept_delete(jour->rtept_list + i); - xfree(jour->rtept_list); - xfree(jour->avoid_os_list); - xfree(jour->buf); - xfree(jour); + free(jour->rtept_list); + free(jour->avoid_os_list); + free(jour->buf); + free(jour); } -struct journey * process_journey_stream (char* jour_in_file_name, +struct journey * process_journey_stream (char* jour_in_file_name, struct pushpin_safelist * ppplist) { int j; @@ -136,7 +136,7 @@ struct journey * process_journey_stream (char* jour_in_file_name, fprintf(stderr, "Quitting because I cannot open %s\n", jour_in_file_name); exit(1); } - + bytes2read=sizeof(struct f_jour_header); jour->buf=(char*)xmalloc(jour->buf_len+bytes2read); status = readbytes(jour_in_file, jour->buf, bytes2read); @@ -196,7 +196,7 @@ struct journey * process_journey_stream (char* jour_in_file_name, memcpy(jour->rtept_list[j].text1, jour->buf + jour->buf_len, bytes2read); jour->rtept_list[j].text1[bytes2read]=0; jour->buf_len += bytes2read; - + str2ascii(jour->rtept_list[j].text1); } if (opts.explore_flag) @@ -274,23 +274,23 @@ struct journey * process_journey_stream (char* jour_in_file_name, lat=jour->rtept_list[j].pushpin->lat; lon=jour->rtept_list[j].pushpin->lon; - printf("Matching pushpin Grid %#x=%d, Precision %#x=%d, MOBBId %#x=%d\n", - jour->rtept_list[j].pushpin->Grid, - jour->rtept_list[j].pushpin->Grid, - jour->rtept_list[j].pushpin->Precision, - jour->rtept_list[j].pushpin->Precision, - jour->rtept_list[j].pushpin->MOBBId, + printf("Matching pushpin Grid %#x=%d, Precision %#x=%d, MOBBId %#x=%d\n", + jour->rtept_list[j].pushpin->Grid, + jour->rtept_list[j].pushpin->Grid, + jour->rtept_list[j].pushpin->Precision, + jour->rtept_list[j].pushpin->Precision, + jour->rtept_list[j].pushpin->MOBBId, jour->rtept_list[j].pushpin->MOBBId); - printf("Matching pushpin Lat %f Lon %f\n", - jour->rtept_list[j].pushpin->lat, + printf("Matching pushpin Lat %f Lon %f\n", + jour->rtept_list[j].pushpin->lat, jour->rtept_list[j].pushpin->lon); x = cos(lon*M_PI/180)*cos(lat*M_PI/180); y = sin(lon*M_PI/180)*cos(lat*M_PI/180); z = sin(lat*M_PI/180); - printf("For matching pushpin X=%f Y=%f Z=%f\n", x,y,z); + printf("For matching pushpin X=%f Y=%f Z=%f\n", x,y,z); } */ } @@ -347,7 +347,7 @@ struct journey * process_journey_stream (char* jour_in_file_name, jour->buf=(char*)xrealloc(jour->buf, jour->buf_len+bytes2read); status = readbytes(jour_in_file, jour->buf + jour->buf_len, bytes2read); if (status!=bytes2read) - { + { printf("Unexpected EOF in the Journey stream, options eur10\n"); fclose(jour_in_file); return jour; diff --git a/st2gpx/src/ppinutil.c b/st2gpx/src/ppinutil.c index df17bb6f4..8f27e3040 100644 --- a/st2gpx/src/ppinutil.c +++ b/st2gpx/src/ppinutil.c @@ -56,16 +56,16 @@ void pushpin_safelist_delete(struct pushpin_safelist * ppl) int i; if (ppl==NULL) return; - + for (i=0; inum_pushpins; i++) pushpin_delete(ppl->pushpin_list[i]); - - xfree(ppl->pushpin_list); - + + free(ppl->pushpin_list); + for(i=0; i<3; i++) - xfree(ppl->UDM_Data[i]); + free(ppl->UDM_Data[i]); - xfree(ppl); + free(ppl); } struct pushpin * pushpin_new() @@ -86,13 +86,13 @@ void pushpin_delete(struct pushpin * pp) { if(pp==NULL) return; - xfree(pp->NoteShort); - xfree(pp->UdName); - xfree(pp); + free(pp->NoteShort); + free(pp->UdName); + free(pp); } -struct point grid2latlon(long grid, long precision) -//struct point ms2latlong(struct ms_point msp) +struct point grid2latlon(long grid, long precision) +//struct point ms2latlong(struct ms_point msp) { // Convert the 2 long values in UserData stream to GPS coordinates. @@ -119,7 +119,7 @@ struct point grid2latlon(long grid, long precision) p.lon=-180; return p; } - for(i=0; i<16; i++) + for(i=0; i<16; i++) { lat_val += (lat_mask & grid) >> i; lon_val += (lon_mask & grid) >> (i+1); @@ -136,7 +136,7 @@ struct point grid2latlon(long grid, long precision) lat_val=0; lon_val=0; - for (i=0; i<16; i++) + for (i=0; i<16; i++) { lat_val += (lat_mask & precision) >> i; lon_val += (lon_mask & precision) >> (i+1); @@ -155,7 +155,7 @@ struct point grid2latlon(long grid, long precision) if (p.lon > 180) p.lon -= 360; if (p.lat > 180) p.lat -= 360; - if ( (p.lat > 90) || (p.lat < -90) ) + if ( (p.lat > 90) || (p.lat < -90) ) { printf("Got bad lat value %f converting pushpin data, setting.\n"); // p.lat=-180; @@ -184,7 +184,7 @@ struct grid_point latlon2grid(double lat, double lon) { msp.grid += ((mask & lon_grid_ndx) << (i+1)); mask <<= 1; } - + mask=1; for(i=0; i<16; i++) { msp.precision += ((mask & lat_prec_ndx) << i); diff --git a/st2gpx/src/properties.c b/st2gpx/src/properties.c index b8ef5f070..033706438 100644 --- a/st2gpx/src/properties.c +++ b/st2gpx/src/properties.c @@ -57,14 +57,14 @@ typedef struct PROPERTYSETHEADER typedef struct FORMATIDOFFSET { FMTID fmtid ; // semantic name of a section - DWORD dwOffset ; // offset from start of whole property set + DWORD dwOffset ; // offset from start of whole property set // stream to the section } FORMATIDOFFSET; -typedef struct PROPERTYIDOFFSET +typedef struct PROPERTYIDOFFSET { DWORD propid; // name of a property - DWORD dwOffset; // offset from the start of the section to that + DWORD dwOffset; // offset from the start of the section to that // property type/value pair } PROPERTYIDOFFSET; @@ -75,7 +75,7 @@ typedef struct tagPROPERTYSECTIONHEADER PROPERTYIDOFFSET rgPropIDOffset[]; // Array of property locations } PROPERTYSECTIONHEADER; -typedef struct SERIALIZEDPROPERTYVALUE +typedef struct SERIALIZEDPROPERTYVALUE { DWORD dwType; // type tag BYTE rgb[]; // the actual property value @@ -84,15 +84,15 @@ typedef struct SERIALIZEDPROPERTYVALUE /* typedef struct tagENTRY { DWORD propid; // Property ID - DWORD cb; // Count of bytes in the string, including the null + DWORD cb; // Count of bytes in the string, including the null // at the end. - char sz[cb]; // Zero-terminated string. Code page as indicated + char sz[cb]; // Zero-terminated string. Code page as indicated // by property ID one. } ENTRY; typedef struct tagDICTIONARY { DWORD cEntries; // Count of entries in the list. - ENTRY rgEntry[cEntries]; + ENTRY rgEntry[cEntries]; } DICTIONARY; */ @@ -105,9 +105,9 @@ char * fmtid2str(char * str, char * fmtid) // We need to be careful here to get the byte order correct. // This seems to match MS's interpretation. { - sprintf(str, "{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}", - *(unsigned long*)(fmtid), - *(unsigned short*)(fmtid+4), + sprintf(str, "{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}", + *(unsigned long*)(fmtid), + *(unsigned short*)(fmtid+4), *(unsigned short*)(fmtid+6), *(unsigned char*)(fmtid+8), *(unsigned char*)(fmtid+9), @@ -123,11 +123,11 @@ char * fmtid2str(char * str, char * fmtid) struct ole_property_set * ole_property_set_new(int cProps) { - struct ole_property_set * props - =(struct ole_property_set*)xmalloc(sizeof(struct ole_property_set)); + struct ole_property_set * props + =(struct ole_property_set*)xmalloc(sizeof(struct ole_property_set)); props->cProps = cProps; - props->dict=NULL; - props->pPropList = (struct ole_property*)xmalloc(cProps*sizeof(struct ole_property)); + props->dict=NULL; + props->pPropList = (struct ole_property*)xmalloc(cProps*sizeof(struct ole_property)); return props; } @@ -140,19 +140,19 @@ void ole_property_set_delete(struct ole_property_set * props) for(i=0; icProps; i++) { - xfree(props->pPropList[i].buf); + free(props->pPropList[i].buf); // FIXME who owns this memory? Cant free it if it is a pointer into another buff - //xfree(props->pPropList[i]); + //free(props->pPropList[i]); } if (props->dict != NULL) { - xfree(props->dict->ent_propid); - xfree(props->dict->ent_sz); - xfree(props->dict); + free(props->dict->ent_propid); + free(props->dict->ent_sz); + free(props->dict); } - xfree(props->pPropList); - xfree(props); + free(props->pPropList); + free(props); } @@ -173,9 +173,9 @@ struct dictionary * read_dictionary(int ents, char* buf, int bufsize) if (bytes_read>bufsize) { printf("read past end of buffer while reading properties dictionary\n"); - xfree(dict->ent_propid); - xfree(dict->ent_sz); - xfree(dict); + free(dict->ent_propid); + free(dict->ent_sz); + free(dict); return NULL; } @@ -191,10 +191,10 @@ struct dictionary * read_dictionary(int ents, char* buf, int bufsize) { printf("reading dictionary, read entry for propid %#x with name length %d > max allowed length of 128\n", dict->ent_propid[ent_read], this_ent_cb); -// xfree(dict->ent_cb); - xfree(dict->ent_propid); - xfree(dict->ent_sz); - xfree(dict); +// free(dict->ent_cb); + free(dict->ent_propid); + free(dict->ent_sz); + free(dict); return NULL; } @@ -227,7 +227,7 @@ unsigned int get_dict_entry(struct dictionary* dict, DWORD propid) struct ole_property * get_propterty(struct ole_property_set * props, DWORD propid) { unsigned int i; - + if (props==NULL) return NULL; @@ -262,8 +262,8 @@ void print_ole_properties(struct ole_property_set * props) if (dict_ent != -1) name = props->dict->ent_sz[dict_ent]; - wprintf(L"\nproperty %d: has name %s propid %#x, type %#x, and length %d bytes\n", - i, name, props->pPropList[i].propid, + wprintf(L"\nproperty %d: has name %s propid %#x, type %#x, and length %d bytes\n", + i, name, props->pPropList[i].propid, props->pPropList[i].dwType, props->pPropList[i].buflen ); switch(props->pPropList[i].propid) @@ -276,18 +276,18 @@ void print_ole_properties(struct ole_property_set * props) wprintf(L"%#x %s\n", props->dict->ent_propid[j], (props->dict->ent_sz[j])); break; case 1: - printf("This specifies codepage %d (1200=Unicode, 1252=Ansi).\n", + printf("This specifies codepage %d (1200=Unicode, 1252=Ansi).\n", *(USHORT*)(props->pPropList[i].buf) ); break; case 0x80000000: - printf("This specifies locale %d .\n", + printf("This specifies locale %d .\n", *(unsigned short*)(props->pPropList[i].buf) ); break; default: switch(props->pPropList[i].dwType) { case VT_BSTR: //=8 - // the prefix bytecount is still there + // the prefix bytecount is still there wprintf(L"This has value '%ls'\n", props->pPropList[i].buf+4); break; case VT_UNKNOWN: //=13 @@ -339,7 +339,7 @@ struct ole_property_set * read_ole_properties2(char* prop_file_name) status=readbytes(prop_file, (char*)prop_header, sizeof(PROPERTYSETHEADER)); status=readbytes(prop_file, (char*)fmt_id_os, sizeof(FORMATIDOFFSET)); - if ( (prop_header->wByteOrder != 0xFFFE) || (prop_header->wFormat != 0) + if ( (prop_header->wByteOrder != 0xFFFE) || (prop_header->wFormat != 0) || (prop_header->dwReserved != 1) || (fmt_id_os->dwOffset !=0x30) ) { printf("Not a valid properties set header in file %s\n", prop_file_name); @@ -352,7 +352,7 @@ struct ole_property_set * read_ole_properties2(char* prop_file_name) psect_header = (PROPERTYSECTIONHEADER *)xrealloc(psect_header, psect_header->cbSection); section_buff = (char*)psect_header; - status=readbytes(prop_file, (char*)(psect_header->rgPropIDOffset), + status=readbytes(prop_file, (char*)(psect_header->rgPropIDOffset), psect_header->cbSection - sizeof(PROPERTYSECTIONHEADER)); property_set = ole_property_set_new(psect_header->cProperties); @@ -382,8 +382,8 @@ struct ole_property_set * read_ole_properties2(char* prop_file_name) for (i=0; i< psect_header->cProperties; i++) { property_set->pPropList[i].propid = psect_header->rgPropIDOffset[i].propid; - -// property_set->pPropList[i].buf + +// property_set->pPropList[i].buf // = section_buff + psect_header->rgPropIDOffset[i].dwOffset + 4; property_set->pPropList[i].buf = (char*)xmalloc(property_set->pPropList[i].buflen); @@ -396,16 +396,16 @@ struct ole_property_set * read_ole_properties2(char* prop_file_name) for (i=0; i< property_set->cProps; i++) if (property_set->pPropList[i].propid==0) - property_set->dict=read_dictionary(property_set->pPropList[i].dwType, - property_set->pPropList[i].buf, + property_set->dict=read_dictionary(property_set->pPropList[i].dwType, + property_set->pPropList[i].buf, property_set->pPropList[i].buflen); fclose(prop_file); - xfree(prop_header); - xfree(psect_header); - xfree(fmt_id_os); + free(prop_header); + free(psect_header); + free(fmt_id_os); - return property_set; + return property_set; } struct ole_property_set * read_ole_properties(char* source_file_name, char* properties_file_name) @@ -413,13 +413,13 @@ struct ole_property_set * read_ole_properties(char* source_file_name, char* prop char * prop_file_name; struct ole_property_set * strips_property_set=NULL; struct ole_property_set * summary_property_set=NULL; - + if ( (source_file_name==NULL) && (properties_file_name==NULL) ) return NULL; if (source_file_name!=NULL) prop_file_name = (char*)xmalloc(strlen(source_file_name)+40); - else + else prop_file_name = properties_file_name; strcpy(prop_file_name, source_file_name); @@ -445,7 +445,7 @@ struct ole_property_set * read_ole_properties(char* source_file_name, char* prop debug_pause(); - xfree(prop_file_name); + free(prop_file_name); ole_property_set_delete(summary_property_set); return strips_property_set; diff --git a/st2gpx/src/readgpx.c b/st2gpx/src/readgpx.c index e9da430d3..c6e0ccf7d 100644 --- a/st2gpx/src/readgpx.c +++ b/st2gpx/src/readgpx.c @@ -44,7 +44,7 @@ static int cdata_length; //FILE* gpx_in_file=NULL; -char * gpx_elem_name[] = +char * gpx_elem_name[] = { "unknown-element", "wpt", @@ -74,9 +74,9 @@ void gpxpt_delete(struct gpxpt * pt) { if(pt==NULL) return; - xfree(pt->name); - xfree(pt->desc); - xfree(pt); + free(pt->name); + free(pt->desc); + free(pt); } struct gpxpt * gpxpt_copy(struct gpxpt * otherpt) @@ -122,9 +122,9 @@ void gpxrte_delete(struct gpxrte * rte) return; for (i=0; irtept_list_count; i++) gpxpt_delete(rte->rtept_list[i]); - xfree(rte->rtept_list); - xfree(rte->name); - xfree(rte); + free(rte->rtept_list); + free(rte->name); + free(rte); } struct gpxtrk * gpxtrk_new() @@ -142,8 +142,8 @@ void gpxtrk_delete(struct gpxtrk * trk) return; for (i=0; itrkpt_list_count; i++) gpxpt_delete(trk->trkpt_list[i]); - xfree(trk->trkpt_list); - xfree(trk); + free(trk->trkpt_list); + free(trk); } struct gpx_data * gpx_data_new() @@ -165,17 +165,17 @@ void gpx_data_delete(struct gpx_data * data) if(data==NULL) return; - xfree(data->data_source_name); + free(data->data_source_name); for (i=0; iwpt_list_count; i++) gpxpt_delete(data->wpt_list[i]); for (i=0; irte_list_count; i++) gpxrte_delete(data->rte_list[i]); for (i=0; itrk_list_count; i++) gpxtrk_delete(data->trk_list[i]); - xfree(data->wpt_list); - xfree(data->rte_list); - xfree(data->trk_list); - xfree(data); + free(data->wpt_list); + free(data->rte_list); + free(data->trk_list); + free(data); } void print_wptlist(struct gpxpt ** wpt_list, int wpt_list_count) @@ -183,7 +183,7 @@ void print_wptlist(struct gpxpt ** wpt_list, int wpt_list_count) int i; printf("Global waypoints:\n"); for (i=0; ilat, wpt_list[i]->lon, wpt_list[i]->name, wpt_list[i]->desc); } @@ -192,7 +192,7 @@ void print_route(struct gpxrte * rte) int i; printf("Route '%s' with %d route-points:\n", rte->name, rte->rtept_list_count); for (i=0; irtept_list_count; i++) - printf("rtept: lat=%f, lon=%f, name='%s', desc='%s'\n", + printf("rtept: lat=%f, lon=%f, name='%s', desc='%s'\n", (rte->rtept_list)[i]->lat, (rte->rtept_list)[i]->lon, (rte->rtept_list)[i]->name, (rte->rtept_list)[i]->desc); } @@ -210,7 +210,7 @@ void print_track(struct gpxtrk * trk) int i; printf("Track with %d track-points:\n", trk->trkpt_list_count); for (i=0; itrkpt_list_count; i++) - printf("trkpt: lat=%f, lon=%f\n", + printf("trkpt: lat=%f, lon=%f\n", trk->trkpt_list[i]->lat, trk->trkpt_list[i]->lon); } @@ -230,10 +230,10 @@ void print_gpx_data(struct gpx_data * all_data) } char* get_att(char* match, const char **atts) -{ +{ const char **avp = &atts[0]; - while (*avp) { - if (strcmp(avp[0], match) == 0) + while (*avp) { + if (strcmp(avp[0], match) == 0) return (char *)avp[1]; avp+=2; } @@ -325,7 +325,7 @@ void startrtept(void *userData, const char *name, const char **atts) } current_main_element=GPX_ELEM_TYPE_RTEPT; - thisrte->rtept_list=(struct gpxpt **)xrealloc(thisrte->rtept_list, + thisrte->rtept_list=(struct gpxpt **)xrealloc(thisrte->rtept_list, (thisrte->rtept_list_count+1)*sizeof(struct gpxpt *)); thisrte->rtept_list[thisrte->rtept_list_count] = gpxpt_new(); sscanf(get_att("lat", atts), "%lf", &(thisrte->rtept_list[thisrte->rtept_list_count]->lat)); @@ -373,9 +373,9 @@ void endtrk(void *userData, const char *name) } current_main_element=0; -// printf("read end of track%d, with %d points\n", +// printf("read end of track%d, with %d points\n", // dat->trk_list_count, -// dat->trk_list[dat->trk_list_count-1]->trkpt_list_count); +// dat->trk_list[dat->trk_list_count-1]->trkpt_list_count); } // just eat : we join all track segments as a single track @@ -415,7 +415,7 @@ void starttrkpt(void *userData, const char *name, const char **atts) } current_main_element=GPX_ELEM_TYPE_TRKPT; - thistrk->trkpt_list=(struct gpxpt **)xrealloc(thistrk->trkpt_list, + thistrk->trkpt_list=(struct gpxpt **)xrealloc(thistrk->trkpt_list, (thistrk->trkpt_list_count+1)*sizeof(struct gpxpt *)); thistrk->trkpt_list[thistrk->trkpt_list_count]=gpxpt_new(); sscanf(get_att("lat", atts), "%lf", &(thistrk->trkpt_list[thistrk->trkpt_list_count]->lat)); @@ -468,7 +468,7 @@ void endname(void *userData, const char *name) //break; case GPX_ELEM_TYPE_TRKPT: default: - xfree(nameval); + free(nameval); break; } } @@ -508,7 +508,7 @@ void enddesc(void *userData, const char *name) // break; case GPX_ELEM_TYPE_TRKPT: default: - xfree(desc); + free(desc); break; } } @@ -523,7 +523,7 @@ void endsrc(void *userData, const char *name) #define GPX_NUM_ELEM_HANDLERS 10 -gpx_elm_start_handler gpx_start_elm_handler[] = +gpx_elm_start_handler gpx_start_elm_handler[] = { &startunkn, &startwpt, @@ -537,7 +537,7 @@ gpx_elm_start_handler gpx_start_elm_handler[] = &startsrc }; -gpx_elm_end_handler gpx_end_elm_handler[] = +gpx_elm_end_handler gpx_end_elm_handler[] = { &endunkn, &endwpt, @@ -567,7 +567,7 @@ startElement(void *userData, const char *name, const char **atts) int i = get_gpx_type_ndx(name); gpx_start_elm_handler[i](userData, name, atts); - xfree(cdata); + free(cdata); cdata=NULL; cdata_length=0; @@ -623,7 +623,7 @@ struct gpx_data * process_gpx_in_file(char* gpx_in_file_name) printf("Importing data from %s\n", gpx_in_file_name); gpx_in_file = fopen(gpx_in_file_name, "r"); } - + if(gpx_in_file==NULL) { fprintf(stderr, "Unable to open GPX file %s\n", gpx_in_file_name); @@ -631,11 +631,11 @@ struct gpx_data * process_gpx_in_file(char* gpx_in_file_name) exit(1); } - do + do { size_t len = fread(buf, 1, sizeof(buf), gpx_in_file); done = len < sizeof(buf); - if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) + if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) { fprintf(stderr, "%s at line %d\n", @@ -650,7 +650,7 @@ struct gpx_data * process_gpx_in_file(char* gpx_in_file_name) { } - xfree(cdata); + free(cdata); return all_data; } diff --git a/st2gpx/src/st2gpx.c b/st2gpx/src/st2gpx.c index cc4bd2001..864980ed8 100644 --- a/st2gpx/src/st2gpx.c +++ b/st2gpx/src/st2gpx.c @@ -57,11 +57,7 @@ void * xmalloc(size_t size) debug_pause(); exit(-1); } -//#ifdef _DEBUG -// obj = _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__ ); -//#else obj = malloc(size); -//#endif if (!obj) { fprintf(stderr, "Unable to allocate %d bytes of memory.\n", size); @@ -69,12 +65,6 @@ void * xmalloc(size_t size) exit(-1); } -#ifdef _DEBUG -#ifdef MEMTRACE - printf("Malloc'd %d bytes at %lx\n", size, obj); -#endif -#endif - return obj; } @@ -88,17 +78,7 @@ void * xrealloc(void* ptr, size_t size) exit(-1); } -#ifdef _DEBUG -#ifdef MEMTRACE - printf("reallocing from %lx\n", ptr); -#endif -#endif - -//#ifdef _DEBUG -// obj = _realloc_dbg(ptr, size, _NORMAL_BLOCK, __FILE__, __LINE__ ); -//#else obj = realloc(ptr, size); -//#endif if (!obj) { fprintf(stderr, "Unable to (re)allocate %d bytes of memory.\n", size); @@ -106,31 +86,9 @@ void * xrealloc(void* ptr, size_t size) exit(-1); } -#ifdef _DEBUG -#ifdef MEMTRACE - printf("realloc'd %d bytes at %lx\n", size, obj); -#endif -#endif - return obj; } -void xfree(void * obj) -{ -//#ifdef _DEBUG -// _free_dbg(obj, _NORMAL_BLOCK); -//#else - -#ifdef _DEBUG -#ifdef MEMTRACE - printf("freeing mem at %lx\n", obj); -#endif -#endif - - free(obj); -// #endif -} - char * str2ascii(char* str) { int i; @@ -147,7 +105,7 @@ char * str2ascii(char* str) } char * strappend(char* str1, char* str2) -// create a new string +// create a new string { int len1=strlen(str1); int len2=strlen(str2); @@ -256,12 +214,10 @@ main(int argc, char** argv) struct gpx_data* all_gpx=NULL; struct ole_property_set * strips_properties=NULL; struct ole_property * prop = NULL; - struct contents * conts; + struct contents * conts=NULL; char* temp_str=NULL; -// int verify_eof_flag = 0; - opts.explore_flag=0; opts.use_gpx_route=0; opts.verbose_flag=2; @@ -274,11 +230,11 @@ main(int argc, char** argv) #ifdef MEMCHK // Call _CrtCheckMemory at every allocation and deallocation request. SET_CRT_DEBUG_FIELD(_CRTDBG_CHECK_ALWAYS_DF); - // Keep freed memory blocks in the heaps linked list, assign them the _FREE_BLOCK type, + // Keep freed memory blocks in the heaps linked list, assign them the _FREE_BLOCK type, // and fill them with the byte value 0xDD. SET_CRT_DEBUG_FIELD(_CRTDBG_DELAY_FREE_MEM_DF); - // Perform automatic leak checking at program exit via a call to _CrtDumpMemoryLeaks - // and generate an error report if the application failed to free all the memory + // Perform automatic leak checking at program exit via a call to _CrtDumpMemoryLeaks + // and generate an error report if the application failed to free all the memory // it allocated. SET_CRT_DEBUG_FIELD(_CRTDBG_LEAK_CHECK_DF); #endif @@ -488,9 +444,9 @@ main(int argc, char** argv) if (all_gpx==NULL) printf("Didn't read any usable data from %s ???\n",mpst_in_file_name); printf("Read %d waypoints, %d routes and %d tracks from file %s\n", - all_gpx->wpt_list_count, all_gpx->rte_list_count, + all_gpx->wpt_list_count, all_gpx->rte_list_count, all_gpx->trk_list_count, mpst_in_file_name); - printf("Importing this data as %d lines\n", + printf("Importing this data as %d lines\n", all_gpx->rte_list_count + all_gpx->trk_list_count); } @@ -501,13 +457,13 @@ main(int argc, char** argv) prop = get_propterty(strips_properties, 0x60002); if ((prop!=NULL) && (prop->buf != NULL) ) { - opts.st_version_num = *(int*)(prop->buf); + opts.st_version_num = *(int*)(prop->buf); printf("Autoroute/S&T version in %s is %d\n", opts.source_file_name, opts.st_version_num); } prop = get_propterty(strips_properties, 0x10000); if ((prop!=NULL) && (prop->buf != NULL) ) { - opts.MapName = (WCHAR*)(prop->buf + 4); + opts.MapName = (WCHAR*)(prop->buf + 4); wprintf(L"MapName is %ls\n", opts.MapName); if(wcscmp(opts.MapName, L"USA")==0) opts.isUSA=1; @@ -518,6 +474,7 @@ main(int argc, char** argv) // check the contents stream //if(opts.explore_flag) + if(opts.source_file_name) { temp_str = strappend(opts.source_file_name, ".Contents\\Contents"); conts = read_contents(temp_str); @@ -613,18 +570,18 @@ main(int argc, char** argv) ole_property_set_delete(strips_properties); contents_delete(conts); - xfree(cmdpath); - xfree(ppin_in_file_name); - xfree(jour_in_file_name); - xfree(annot_in_file_name); - xfree(gpx_in_file_name); - xfree(gpx_out_file_name); - xfree(pcx5_out_file_name); - xfree(import_file_name); - xfree(opts.source_file_name); - xfree(contents_dir_name); - xfree(mpst_in_file_name); - + free(cmdpath); + free(ppin_in_file_name); + free(jour_in_file_name); + free(annot_in_file_name); + free(gpx_in_file_name); + free(gpx_out_file_name); + free(pcx5_out_file_name); + free(import_file_name); + free(opts.source_file_name); + free(contents_dir_name); + free(mpst_in_file_name); + if (opts.verbose_flag>5) printf("Done freeing all\n"); @@ -635,7 +592,7 @@ main(int argc, char** argv) _flushall(); #ifdef _DEBUG -// _CrtDumpMemoryLeaks(); +// _CrtDumpMemoryLeaks(); #endif debug_pause(); } diff --git a/st2gpx/src/st2gpx.dsp b/st2gpx/src/st2gpx.dsp index 920d5085d..df25be3bc 100644 --- a/st2gpx/src/st2gpx.dsp +++ b/st2gpx/src/st2gpx.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /Zp1 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /Zp1 /Za /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -75,8 +75,8 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 libexpat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /pdbtype:sept -# SUBTRACT LINK32 /profile /map /debug +# ADD LINK32 libexpat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# SUBTRACT LINK32 /profile /map !ENDIF @@ -93,10 +93,10 @@ SOURCE=.\annotations.c !IF "$(CFG)" == "st2gpx - Win32 Release" -# ADD CPP /Za - !ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" +# SUBTRACT CPP /FA + !ENDIF # End Source File @@ -106,25 +106,16 @@ SOURCE=.\contents.c !IF "$(CFG)" == "st2gpx - Win32 Release" -# ADD CPP /Za - !ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" +# ADD CPP /Za + !ENDIF # End Source File # Begin Source File SOURCE=.\debug.c - -!IF "$(CFG)" == "st2gpx - Win32 Release" - -# ADD CPP /Za - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -!ENDIF - # End Source File # Begin Source File @@ -134,41 +125,14 @@ SOURCE=.\getopt.c # Begin Source File SOURCE=.\journey.c - -!IF "$(CFG)" == "st2gpx - Win32 Release" - -# ADD CPP /Za - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\nannol.c - -!IF "$(CFG)" == "st2gpx - Win32 Release" - -# ADD CPP /Za - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\ppinutil.c - -!IF "$(CFG)" == "st2gpx - Win32 Release" - -# ADD CPP /Za - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -!ENDIF - # End Source File # Begin Source File @@ -178,74 +142,27 @@ SOURCE=.\properties.c # Begin Source File SOURCE=.\pushpins.cpp - -!IF "$(CFG)" == "st2gpx - Win32 Release" - # ADD CPP /Ze - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -# ADD CPP /Ze /W4 /Gi - -!ENDIF - # End Source File # Begin Source File SOURCE=.\readgpx.c - -!IF "$(CFG)" == "st2gpx - Win32 Release" - -# ADD CPP /Za - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\readmpst.c - -!IF "$(CFG)" == "st2gpx - Win32 Release" - -# ADD CPP /Za - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\st2gpx.c -# ADD CPP /Za # End Source File # Begin Source File SOURCE=.\writegpx.c - -!IF "$(CFG)" == "st2gpx - Win32 Release" - -# ADD CPP /Za - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -!ENDIF - # End Source File # Begin Source File SOURCE=.\writepcx.c - -!IF "$(CFG)" == "st2gpx - Win32 Release" - -# ADD CPP /Za - -!ELSEIF "$(CFG)" == "st2gpx - Win32 Debug" - -!ENDIF - # End Source File # End Group # Begin Group "Header Files" @@ -306,6 +223,14 @@ SOURCE=.\history.txt # End Source File # Begin Source File +SOURCE=.\msado15.tlh +# End Source File +# Begin Source File + +SOURCE=.\msado15.tli +# End Source File +# Begin Source File + SOURCE=.\ToDo.txt # End Source File # End Target diff --git a/st2gpx/src/st2gpx.h b/st2gpx/src/st2gpx.h index 03e7fe178..3738383de 100644 --- a/st2gpx/src/st2gpx.h +++ b/st2gpx/src/st2gpx.h @@ -30,7 +30,6 @@ extern "C" { //#define MEMCHK //#define DEBUG_STDOUT -//#define MEMTRACE #ifdef _DEBUG #define _CRTDBG_MAP_ALLOC @@ -99,7 +98,6 @@ extern struct contents; extern struct st2gpx_options opts; void * xmalloc(size_t size); void * xrealloc(void* ptr, size_t size); -void xfree(void * obj); char * str2ascii(char* str); int readbytes(FILE* file, char* buf, int bytes2read); //nannol.c diff --git a/st2gpx/src/writegpx.c b/st2gpx/src/writegpx.c index 34bbcdf23..b61d88aa6 100644 --- a/st2gpx/src/writegpx.c +++ b/st2gpx/src/writegpx.c @@ -139,7 +139,7 @@ void gpx_write_jour_point(FILE* gpx_out_file, struct journey * jour, struct jour gpx_write_point(gpx_out_file, pt, GPX_RTEPT, opt_elms); gpxpt_delete(pt); - xfree(opt_elms); + free(opt_elms); } void gpx_write_jour_header(FILE* gpx_out_file) @@ -191,7 +191,7 @@ void gpx_write_pushpinlist (FILE* gpx_out_file, struct pushpin_safelist *ppplist if (ppplist->pushpin_list[i]==NULL) break; - optlen = strlen(ppplist->pushpin_list[i]->UdName) + optlen = strlen(ppplist->pushpin_list[i]->UdName) + strlen(ppplist->pushpin_list[i]->NoteShort) + 60; opt_elms = (char*)xmalloc(optlen); @@ -202,7 +202,7 @@ void gpx_write_pushpinlist (FILE* gpx_out_file, struct pushpin_safelist *ppplist pt->lon = ppplist->pushpin_list[i]->lon; gpx_write_point(gpx_out_file, pt, GPX_WPT, opt_elms); - xfree(opt_elms); + free(opt_elms); } fprintf(gpx_out_file, "\n"); gpxpt_delete(pt); @@ -300,8 +300,8 @@ void gpx_write_annotations(FILE* gpx_out_file, struct annotations * annots) } } -void gpx_write_all(char* gpx_out_file_name, - struct pushpin_safelist *ppplist, +void gpx_write_all(char* gpx_out_file_name, + struct pushpin_safelist *ppplist, struct journey * jour, struct annotations * annots) { diff --git a/st2gpx/src/writepcx.c b/st2gpx/src/writepcx.c index 89ae0f03b..35e54b6e6 100644 --- a/st2gpx/src/writepcx.c +++ b/st2gpx/src/writepcx.c @@ -86,7 +86,7 @@ void garmin_ident_crush(char* str) str[6]=0; } -void comp_mk_uniq_idents(char* ident_array, int ident_to_mk_uniq, int count_idents) +void comp_mk_uniq_idents(char* ident_array, int ident_to_mk_uniq, int count_idents) // compare ident_to_mk_uniq-th ident to all preceding idents, // and make ident_to_mk_uniq-th ident { @@ -161,7 +161,7 @@ void make_uniq_idents(struct pushpin_safelist * ppplist, struct journey * jour) } else count_ppins=ppplist->num_pushpins; - + ident_array=(char*)xmalloc(7*(count_ppins + jour->count_rtepts)); // copy ppin names before we start mangling them @@ -180,8 +180,8 @@ void make_uniq_idents(struct pushpin_safelist * ppplist, struct journey * jour) // copy rtept names before we start mangling them for (i=0; i< (jour->count_rtepts); i++) { - memcpy(ident_array + 7*(count_ppins) +7*i, - jour->rtept_list[i].text1, + memcpy(ident_array + 7*(count_ppins) +7*i, + jour->rtept_list[i].text1, 6); garmin_ident_crush(ident_array + 7*(count_ppins) + 7*i); } @@ -193,7 +193,7 @@ void make_uniq_idents(struct pushpin_safelist * ppplist, struct journey * jour) // Create a unique ident if neccesary. // Only check against list of already-verified unique comp_mk_uniq_idents(ident_array, i, count_ppins + jour->count_rtepts); - + strncpy(ppplist->pushpin_list[i]->garmin_ident, ident_array+7*i, 7); } @@ -225,24 +225,24 @@ void make_uniq_idents(struct pushpin_safelist * ppplist, struct journey * jour) ppplist->pushpin_list[j]->garmin_ident, 7); // Although the journey stream doesn't associate this pushpin with the route, - // I have decided to. Again, this is questionable + // I have decided to. Again, this is questionable // but not likely to happen anyway. jour->rtept_list[i].pushpin = ppplist->pushpin_list[j]; } else { // no matching wpt for this rtept, so we need to create one. - // We just create the garmin_ident in the jour-rtept here, + // We just create the garmin_ident in the jour-rtept here, // later we will write a corresponding wpt to the pcx file. comp_mk_uniq_idents(ident_array, count_ppins + i, count_ppins + jour->count_rtepts); - } + } } // set the jour-rtept garmin_ident memcpy(jour->rtept_list[i].garmin_ident, ident_array + 7*(count_ppins) +7*i, 7); } - xfree(ident_array); + free(ident_array); } void gar_write_header(FILE* gar_out_file) @@ -352,18 +352,18 @@ void pcx5_write_jour_pt(FILE* file, struct journey * jour, struct jour_rtept * r memcpy(desc, rtept->text1,39); strpad(desc, 40); - - pcx5_write_pt(file, - pt_type, - rtept->garmin_ident, - scaled2deg(f_wpt_head->scaled_lat), - scaled2deg(f_wpt_head->scaled_lon), - timedate, - alt, - desc, - proximity, + + pcx5_write_pt(file, + pt_type, + rtept->garmin_ident, + scaled2deg(f_wpt_head->scaled_lat), + scaled2deg(f_wpt_head->scaled_lon), + timedate, + alt, + desc, + proximity, symbol); - + // } // else if(pt_type==GAR_RTE) // { -- 2.30.2